<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    #wai{
      width: 300px;
      height: 300px;
      background-color: blue;
      border: 10px salmon solid;
      margin: 60px;
      overflow: hidden;
    }
    #nei{
      width: 100px;
      height: 100px;
      background-color: red;
      border: 10px thistle solid;
      margin: 50px;
      padding: 10px;
    }
  </style>
</head>
<body>
  <div id="wai">
    <div id="nei"></div>
  </div>
  <script>
    var wai =document.querySelector("#wai");
    var nei = document.querySelector("#nei");
    var nei1 = document.getElementById("nei");
  //偏移参考父级 
  // 距离自己最近的有定位的父级，如果都没有定位参考body(html)
    console.log(nei1.offsetParent);
  // 偏移位置 距离自己最近的有定位的父级的距离
    console.log(nei1.offsetLeft);
    console.log(nei1.offsetTop);
    // 偏移大小  content+padding+border
    console.log(nei1.offsetWidth);
    console.log(nei1.offsetHeight);
    
  </script>
</body>
</html>